import { getcateListApi } from '../api/cate'
import { ref, reactive, onMounted } from 'vue'
export const useListAsync = () => {
  const list = ref([])
  const count = ref(0)
  const getList = async (url, params) => {
    let res = await getcateListApi(url, params)
    // console.log(res);
    list.value = res.data.rows
    count.value = res.data.count
  }
  return { list, getList, count }
}

export const formatTimestamp = (timestamp) => {
  const date = new Date(timestamp);

  const year = date.getFullYear();
  const month = (date.getMonth() + 1).toString().padStart(2, '0');
  const day = date.getDate().toString().padStart(2, '0');
  const hours = date.getHours().toString().padStart(2, '0');
  const minutes = date.getMinutes().toString().padStart(2, '0');
  const seconds = date.getSeconds().toString().padStart(2, '0');

  return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}

